package com.zxy;

public class demo02 {
    public static void main(String[] args) {
        //定义一个数组
        int[] arr = new int[]{1, 2, 3, 4, 5, 5, 6, 7};
        int num = 10;
        //定义索引
        int index = -1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == num) {
                index = i;
                System.out.println(num + "的索引为" + index);
                break;
            }
        }
        if (index < 0) {
            System.out.println(num + "不存在");
        }

    }
}
